package com.wtp.wallpaper.controller.user;

import com.wtp.wallpaper.pojo.entity.BannerPic;
import com.wtp.wallpaper.pojo.query.PageQuery;
import com.wtp.wallpaper.pojo.vo.BannerPicVO;
import com.wtp.wallpaper.pojo.result.Result;
import com.wtp.wallpaper.service.BannerPicService;
import com.wtp.wallpaper.utils.PojoConvertUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "banner相关接口")
@RestController
@Slf4j
public class BannerPicController {

    @Autowired
    private BannerPicService bannerPicService;

    @Operation(summary = "获取主页banner")
    @GetMapping("/homeBanner")
    //@ReplaceURL
    public Result getHomeBanner(PageQuery pageQuery){
        log.info("pageQuery:{}",pageQuery);
        List<BannerPic> homeBannerList = bannerPicService.getHomeBannerList(pageQuery);
        return Result.success(PojoConvertUtil.convert(homeBannerList, BannerPicVO.class));
    }
}
